package com.hzy.yiyaoba.bean;

import java.util.ArrayList;
import java.util.List;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.hzy.yiyaoba.utils.Config;
import com.hzy.yiyaoba.utils.Config.LoreConfig;

//"name":"减肥瘦身",
//"id":11

public class LoreClass {
	private int id;
	private String name;

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public LoreClass(int id, String name) {
		super();
		this.id = id;
		this.name = name;
	}

	public static List<LoreClass> parseLoreClassList(String json) throws Exception {
		List<LoreClass> list = new ArrayList<LoreClass>();
		JSONObject obj = JSON.parseObject(json);
		if (!obj.getBoolean(Config.JSON_SUCCESS)) {
			return null;
		}
		JSONArray arr = obj.getJSONArray(Config.JSON_CONTENT);
		for (int i = 0; i < arr.size(); i++) {
			obj = arr.getJSONObject(i);
			list.add(new LoreClass(obj.getInteger(LoreConfig.JSON_ID), obj.getString(LoreConfig.JSON_NAME)));
		}
		return list;
	}

}
